import 'package:flutter/material.dart';

class DrawerWidget extends StatelessWidget {
  
  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: ListView(
        padding: EdgeInsets.zero,
        children: <Widget> [
          // DrawerHeader(
          //   child: Text("Header".toUpperCase()),
          //   decoration: BoxDecoration(
          //     color: Colors.grey[100]
          //   ),
          // ),
          UserAccountsDrawerHeader(
            // 设置用户名
            accountName: Text("张三", style: TextStyle(fontWeight: FontWeight.bold),), 
            // 设置用户邮箱
            accountEmail: Text("sdcnljg@163.com", style: TextStyle(fontWeight: FontWeight.bold),),
            // 设置用户头像
            currentAccountPicture: CircleAvatar(
              backgroundImage: AssetImage ('assets/images/avatar.png'),
            ),
            // 添加背景图像
            decoration: BoxDecoration(
              color: Colors.green[400],
              image: DecorationImage(
                image: AssetImage('assets/images/3.jpg'), // 设置背景图片
                fit: BoxFit.cover, // 设置图像填充
                colorFilter: ColorFilter.mode(Colors.green[400].withOpacity(0.5), BlendMode.srcOver)
              )
            ),
          ),
          ListTile(
            title: Text("Messages", textAlign: TextAlign.right),
            trailing: Icon(Icons.message, color: Colors.black12, size: 22.0),
            // 添加点击自动关闭抽屉事件
            onTap: () => Navigator.pop(context),
          ),
          ListTile(
            title: Text("Favorite", textAlign: TextAlign.right),
            trailing: Icon(Icons.favorite, color: Colors.black12, size: 22.0),
            // 添加点击自动关闭抽屉事件
            onTap: () => Navigator.pop(context),
          ),
          ListTile(
            title: Text("Settings", textAlign: TextAlign.right),
            trailing: Icon(Icons.settings, color: Colors.black12, size: 22.0),
            // 添加点击自动关闭抽屉事件
            onTap: () => Navigator.pop(context),
          )
        ],
      ),
    );
  }
}